define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		//配件商品
		function get_data_productmanager_publish_more_goods(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"goods": ['+
				'{"id": "001","name": "螺丝刀", "bn": "新品","specification": "规格001","price": 10},'+
				'{"id": "002","name": "螺丝","bn": "新品","specification": "规格002","price": 2},'+
				'{"id": "003","name": "螺丝22","bn": "新品","specification": "规格002","price": 50}'+
				']},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		
		//编辑
		function get_data_productmanager_publish_more_edit(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": { "id": "001"},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		
		
		//返回信息
		return {
			//商品配件
			productmanager_publish_more_goods: function(callback) {
				Http.post({
						method: 'goods.suitgoods.getlist',
					},
					function(result) {
						//请求成功
						if(callback)
							callback(get_data_productmanager_publish_more_goods(result).result);
					},
					function(e) {
						//请求异常
					},
					function() {
						//请求完成，一般不做什么事情
					});
			},
			//商品编辑
			productmanager_publish_more_edit: function(name,id,goods_id,min_count,max_count,privilege_type,privilege,goods,callback) {
				Http.post({
						method: 'goods.suitgoods.edit',
						updateParams:{
							name:name,				//配件组名称
							id:id,					//配件ID
							goods_id:goods_id,		//对应商品ID
							min_count:min_count,	//最小购买量
							max_count:max_count,	//最大购买量
							privilege_type:privilege_type,		//优惠类型，1：折扣；2：金额
							privilege:privilege,	//优惠额度，默认为0
							goods:goods				//配件商品
						}
					},
					function(result) {
						//请求成功
						if(callback)
							callback(get_data_productmanager_publish_more_edit(result));
					},
					function(e) {
						//请求异常
					},
					function() {
						//请求完成，一般不做什么事情
					});
			},
			
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Productmanager_publish_more", factory);
});